/**
 * @Title: warningExamineResult_ctrl.js
 * @Description: TODO
 * Copyright: Copyright (c) 2014
 * Company:中国平安
 *
 * @Project mhis-fwa
 * @author EX-LILIUZHU001
 * @date 2014年11月14日 上午9:25:31
 * @version V1.0
 */
;
(function(){
	'use strict';	
	var app = angular.module('fwa.mainApp');
	app.controller('WarningExamineResultCtrl', ['$scope','$modal','$stateParams','BaseURL','Modal','WarningScreenService','WarningAddService',
	                                function($scope,$modal,$stateParams,baseUrl,Modal,WarningScreenService,WarningAddService){
		$scope.warningScreenService = WarningScreenService;
		$scope.WarningAddService = WarningScreenService;
		$scope.approveWarn = {};
		var codeType=['audit_research_check'];
		var warnNo=$stateParams.warnNo;
		WarningScreenService.getWarnExamineResult({warnNo:warnNo})
		.success(function(res){
				$scope.codedesc=res.codedesc;
				$scope.sumamount=res.sumamount;
				$scope.point=res.point;
	     });
		WarningAddService.getHcpmsCodeList(codeType).success(function(response){
			$scope.codetypes = response.result;			
		});
		//审批意见保存
		$scope.submitWarning = function (){
			$scope.approveWarn = {};
			alert($scope.approveWarn.codetype);
			if($scope.approveWarn.codetype === '0'&&!$scope.approveWarn.optionexplain){
				Modal.alert("意见说明不能为空!");
				return;
			}			
		   var param={warnNo:warnNo,
				   approveOpinion:$scope.approveWarn.codetype,
				   approveDesc:$scope.approveWarn.optionexplain};
		   WarningAddService.saveApprovalResult(param).success(function(res){
			   Modal.alert(res.msg);
			   //if(res.state='0') {
				//   $state.go("warning.warningList");                  
               //}
           });
		}
	}]).
	controller('WarningEditCheckResultCtrl',
			['$scope','$stateParams','BaseURL', 'Modal','WarningScreenService', function($scope,$stateParams, baseUrl, Modal,WarningScreenService){
				$scope.warningScreenService = WarningScreenService;				
				var warnNo = "";
				if($stateParams.warnNo&&!angular.isUndefined($stateParams.warnNo)){
					warnNo = $stateParams.warnNo;
				}
				WarningScreenService.getWarningEditCheckResult({warnno:warnNo}).
				success(function(res){					
					$scope.measure = res.measure;					
					$scope.situation = res.situation;
					$scope.sumamount = res.sumamount;					
					$scope.detailList = res.detailList;					
					var amount = "0";
					if(res.detaiList){
						angular.forEach(res.detaiList,function(data,index){
							amount = parseFloat(amount) + parseFloat(data.amount);
						   });
					}
					$scope.totalDetaiListAmount = amount;
				});
	}]);	
})();